package com.example.javamaday.leetcode;

import java.util.Comparator;
import java.util.PriorityQueue;

public class LeetCodeTest1464 {

    public static void main(String[] args) {

    }


    public int maxProduct(int[] nums) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(2, new Comparator<Integer>() {
            @Override
            public int compare(Integer integer, Integer t1) {
                return integer.compareTo(t1);
            }
        });
        for (int j : nums) {
            priorityQueue.offer(j);
            if (priorityQueue.size() > 2) {
                priorityQueue.poll();
            }
        }
        int x = priorityQueue.poll();
        int y = priorityQueue.poll();
        return (x - 1) * (y - 1);
    }


}
